package com.flyme.module.base.provider.aliyunren;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.cloudauth.model.v20190307.DescribeVerifyTokenRequest;
import com.aliyuncs.cloudauth.model.v20190307.DescribeVerifyTokenResponse;
import com.aliyuncs.cloudauth.model.v20190307.VerifyMaterialRequest;
import com.aliyuncs.cloudauth.model.v20190307.VerifyMaterialResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;


public class VerifyMaterial {


    public String verifyMaterial(String FaceImageUrl, String bizType, String BizId, String name, String idCardNumber) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4G1dJyiqxV13hmrppUea", "rHrmSTgV5aZNhMAba4dvxG3gCOTB18");
        IAcsClient client = new DefaultAcsClient(profile);

        VerifyMaterialRequest request = new VerifyMaterialRequest();
        request.setRegionId("cn-hangzhou");
        request.setFaceImageUrl(FaceImageUrl);
        request.setBizType(bizType);
        request.setBizId(BizId);
        request.setName(name);
        request.setIdCardNumber(idCardNumber);
        try {
            VerifyMaterialResponse response = client.getAcsResponse(request);
            return new Gson().toJson(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    public String describeVerifyToken(String FaceRetainedImageUrl, String bizType, String BizId) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4G1dJyiqxV13hmrppUea", "rHrmSTgV5aZNhMAba4dvxG3gCOTB18");
        IAcsClient client = new DefaultAcsClient(profile);

        DescribeVerifyTokenRequest request = new DescribeVerifyTokenRequest();
        request.setRegionId("cn-hangzhou");
        request.setBizId(BizId);
        request.setBizType(bizType);
        request.setFaceRetainedImageUrl(FaceRetainedImageUrl);
        try {
            DescribeVerifyTokenResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
            return new Gson().toJson(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
          return null;
    }



    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4G1dJyiqxV13hmrppUea", "rHrmSTgV5aZNhMAba4dvxG3gCOTB18");
        IAcsClient client = new DefaultAcsClient(profile);
//        VerifyMaterialRequest request = new VerifyMaterialRequest();
//        request.setRegionId("cn-hangzhou");
//        request.setFaceImageUrl("http://cbstudy.oss-cn-shenzhen.aliyuncs.com/1538139a14504b1f8eb3d1e64260badd.jpg");
//        request.setBizType("signexam");
//        request.setBizId("39ecf51e-2f81-4dc5-90ee-ff86125be684");
//        request.setName("叶兴刚");
//        request.setIdCardNumber("410329199203223033");
        DescribeVerifyTokenRequest request = new DescribeVerifyTokenRequest();
        request.setRegionId("cn-hangzhou");
        request.setBizId("39ecf51e-2f81-4dc5-90ee-ff86125be684");
        request.setBizType("FVUse");
        request.setFaceRetainedImageUrl("http://cbstudy.oss-cn-shenzhen.aliyuncs.com/1538139a14504b1f8eb3d1e64260badd.jpg");
        try {
//            VerifyMaterialResponse response = client.getAcsResponse(request);
            DescribeVerifyTokenResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
